$(function() {
    let index = parent.layer.getFrameIndex(window.name);
    parent.layer.iframeAuto(index);
    
    $(".select-item-fmea-customProduct").on("click", function() {
    	let $this = $(this);
        let id = $this.data("id");
        let $input = parent.clickTarget;
        if (parent.layui.$("td input[name='productId'][value='" + id + "']").size() == 0) {
            $input.val($this.data('code'));
            $input.siblings("input[name='productId']").val(id);
            $input.parentsUntil('tbody').find('.delete-row').attr('id', id);
        } else {
            parent.layer.tips("已选择", $input.parents("table").find(".delete-row[id='" + id + "']"), {
                time : 3000
            });
        }
        parent.layer.close(index);
    });
    
    
    $(".select-item-fmea-product-dfmea-step1").on("click", function() {
    	let $this = $(this);
    	let id = $this.data("id");
    	let $input = parent.clickTarget;
    	if (parent.layui.$("td input[name='productId'][value='" + id + "']").size() == 0) {
    		let $form = $(parent.document).find("form");
    		let action = $form.attr("action");
    		let urlId = $form.find("input[name='id']").val();
    		parent.location.href = action.slice(0, action.lastIndexOf("/")) + "/step1/" + urlId + "?productId=" + id;
    	} else {
    		parent.layer.tips("已选择", $input, {
    			time : 3000
    		});
    	}
    	parent.layer.close(index);
    });

     

});